package com.wlyuan.open.infrastructure.repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wlyuan.core.marker.NamedStatus;
import com.wlyuan.open.dao.entity.PushTenantDO;
import com.wlyuan.open.dao.mapper.PushTenantMapper;
import com.wlyuan.open.domain.PushBusinessType;
import com.wlyuan.open.domain.PushTaskId;
import com.wlyuan.open.domain.PushTenant;
import com.wlyuan.open.domain.repository.PushTenantRepository;
import com.wlyuan.open.infrastructure.converter.PushTenantConverter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author
 * 对接表
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class PushTenantRepositoryImpl implements PushTenantRepository {
    private final PushTenantMapper pushTenantMapper;

    @Override
    public PushTenant ofTenantAndType(Long tenantId, PushBusinessType businessType) {
        QueryWrapper<PushTenantDO> query = new QueryWrapper<>();
        query.lambda().eq(PushTenantDO::getTenantId,tenantId);
        query.lambda().eq(PushTenantDO::getBusinessType,businessType.getValue());
        query.lambda().eq(PushTenantDO::getStatus, NamedStatus.ENABLED.getValue());
        PushTenantDO pushTenantDO = pushTenantMapper.selectOne(query);
        return PushTenantConverter.convert(pushTenantDO);
    }

    @Override
    public PushTenant ofId(PushTaskId pushTaskId) {
        return null;
    }

    @Override
    public PushTaskId save(PushTenant object) {
        return null;
    }

    @Override
    public void remove(PushTaskId pushTaskId) {

    }
}
